package com.bjwl.service.impl;

import com.bjwl.dao.ServerClassMapper;
import com.bjwl.pojo.CardDenomination;
import com.bjwl.pojo.ServiceClass;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.ServerClassService;
import com.bjwl.utils.Log4jUtils;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/9 13:56
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class ServerClassServiceImpl implements ServerClassService {

    @Autowired
    private ServerClassMapper serverClassMapper;

    @Override
    public boolean addServiceClass(ServiceClass serviceClass) {

            serverClassMapper.addServiceClass(serviceClass);
            return true;

    }

    @Override
    public PageBean<ServiceClass> findAllServiceClass(BasicQueryVo vo) {
        PageBean<ServiceClass> pageBean = new PageBean<ServiceClass>(vo.getPageNum(),10,serverClassMapper.getTotalRecord(vo));
        pageBean.setData(serverClassMapper.findAllServiceClass(pageBean,vo));
        return pageBean;
    }


    @Override
    public ServiceClass editStart(Integer id) {
        return serverClassMapper.findServiceClassById(id);
    }

    @Override
    public boolean updateServiceClass(ServiceClass serviceClass) {

            Integer state = serverClassMapper.updateServiceClass(serviceClass);
            return true;

    }

    @Override
    public boolean deleteServiceClass(Integer id) {
        try {
            serverClassMapper.deleteServiceClass(id);
        }catch (Exception e){
            Log4jUtils.LITERAL3.getLog().error(e.getMessage());
        }
        return true;
    }
}
